<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>


将两个数组中相同的元素放在一个新数组中
        var arr=[1,4,2,6,3,2,6,3];
        var arr1=[4,6,7,9,0,2,2,6];

        var arr2=arr.reduce(function(value,item){
            if(arr1.indexOf(item)>-1 && value.indexOf(item)<0) value.push(item);
            return value;
        },[]);
        console.log(arr2);











        
      将两个数组中不同的元素放在一个新数组中
      var arr=[1,4,2,6,3,2,6,3];
        var arr1=[4,6,7,9,0,2,2,6];

        var arr2=arr.concat(arr1);
        var arr3=[];
        arr2.forEach(function(item,index){
            var list=arr2.reduce(function(value,item1,index1){
                if(item===item1) value.push(index1);
                return value;
            },[]);
            if(list.length===1) arr3.push(item);
        })
        console.log(arr3);






















    </script>
</body>
</html>